<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<ui:include src="include/head.xhtml" />
</h:head>
<h:body>
	<ui:include src="include/header.xhtml" />
	<div class="main">
	<table width="100%">
		<tr>
			<td width="15%" valign="top">
				<ui:include src="include/menu.xhtml" />
			</td>
			<td class="main" valign="top">
				<table width='100%'>
					<tr>
						<td valign="top" width="25%;">
							<div>
								<div class="panel-header">Выберите факультет:</div> 
							<h:dataTable value="#{groupsBean.faculties.items}" var="f"
								binding="#{groupsBean.faculties.dataTable}">
								<h:column>
									<a class="#{groupsBean.faculties.style}"
										href="http://localhost:8080/university-web/groups/#{f.id}/">#{f.title}</a>
								</h:column>
							</h:dataTable></div>
							<br />
							<div>
							<h:panelGroup rendered="#{groupsBean.faculties.id != null}">
								<div class="panel-header">Выберите группу:</div> 
								<h:dataTable value="#{groupsBean.groups.items}" var="g"
									binding="#{groupsBean.groups.dataTable}">
									<h:column>
										<a class="#{groupsBean.groups.style}"
											href="http://localhost:8080/university-web/groups/#{groupsBean.faculties.id}/#{g.id}">#{g.title}</a>
									</h:column>
								</h:dataTable>
							</h:panelGroup>
							</div>
						</td>
						<td valign="top">
							<div>
								<h:panelGroup rendered="#{groupsBean.groups.id != null}">
									<div class="panel-header">Список студентов:</div> 
									<h:form >
										<h:dataTable value="#{groupsBean.students.items}" 
										             var="s" 
										             style="width:100%;" 
										             binding="#{groupsBean.students.dataTable}">
											<h:column>
												<h:outputText value="#{s.fullName}" rendered="#{!groupsBean.editMode}" />
												<h:inputText style="width:80%;" value="#{s.fullName}" rendered="#{groupsBean.editMode}" />
												<h:commandButton value="Удалить" 
										                 action="#{groupsBean.deleteStudent}" 
										                 rendered="#{groupsBean.editMode}" />
											</h:column>
										</h:dataTable>
										<br />
										<h:panelGroup rendered="#{groupsBean.editMode}">
											Добавить нового студента: 
											<h:inputText style="width:100%;" 
												value="#{groupsBean.newbieName}" 
												rendered="#{groupsBean.editMode}" />
										</h:panelGroup>
										<h:commandButton value="Сохранить" 
										                 action="#{groupsBean.save}" 
										                 rendered="#{groupsBean.editMode}" />
										<h:commandButton value="Завершить" 
										                 action="#{groupsBean.finishEdit}" 
										                 rendered="#{groupsBean.editMode}" />
									</h:form>
								</h:panelGroup>
							</div>
						</td>
						<td valign="top" width="25%;">
							<div>
								<h:panelGroup rendered="#{groupsBean.groups.id != null}">
									<div class="panel-header">Выберите действие:</div> 
									<a style='font-size: 20px;' href='http://localhost:8080/university-web/schedule/#{groupsBean.groups.id}/'>
										Перейти к расписанию</a>
									<br />
									<a style='font-size: 20px;' href='http://localhost:8080/university-web/progress/#{groupsBean.groups.id}/'>
										Перейти к успеваемости
									</a>
									<br />
									<h:panelGroup rendered="#{authBean.loggedInAsAdmin}">
										<a style='font-size: 20px;' href='http://localhost:8080/university-web/groups/#{groupsBean.faculties.id}/#{groupsBean.groups.id}/edit'>
											Изменить состав
										</a>
										<br />
									</h:panelGroup>
								</h:panelGroup>
							</div>
						</td>
					</tr>
				</table>
			<h:messages /></td>
		</tr>
	</table>
	</div>
</h:body>
</html>